package com.management.controller;


import com.management.controller.form.*;
import com.management.service.DefectTypeService;
import com.management.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 龙世超
 * @since 2022-03-23
 */
@Api(tags = "缺陷类型相关")
@RestController
@RequestMapping("/defectType")
public class DefectTypeController {

    /**
     * 从容器中取出缺陷类型业务对象
     */
    @Resource
    private DefectTypeService defectTypeService;

    /**
     * 获取所有缺陷类型并分页
     * @param getTypePageForm 继承Page,获取前端传过来的页码数和当前页的数据条数
     * @return
     */
    @ApiOperation("获取所有缺陷类型并分页")
    @PostMapping("/GetType")
    public Result GetType(@RequestBody GetTypePageForm getTypePageForm){
        return defectTypeService.FindType(getTypePageForm);
    }

    /**
     * 创建缺陷类型
     * @param createTypeForm
     * @return
     */
    @ApiOperation("创建缺陷类型")
    @PostMapping("/createType")
    public Result createType(@RequestBody CreateTypeForm createTypeForm){
        return defectTypeService.addType(createTypeForm);
    }

    /**
     * 移除缺陷类型
     * @param removeTypeForm
     * @return
     */
    @ApiOperation("移除缺陷类型")
    @PostMapping("/removeTypeBytypeId")
    public Result removType(@RequestBody RemoveTypeForm removeTypeForm){
        return defectTypeService.removType(removeTypeForm);
    }

    /**
     * 批量移除缺陷类型
     * @param removeBytypeIdsForm
     * @return
     */
    @ApiOperation("批量移除缺陷类型")
    @PostMapping("/removeBytypeIds")
    public Result removeBytypeIds(@RequestBody RemoveBytypeIdsForm removeBytypeIdsForm){
        return defectTypeService.removeBytypeIds(removeBytypeIdsForm);
    }

    /**
     * 禁用某类型
     * @param disableTypeForm
     * @return
     */
    @ApiOperation("禁用某类型")
    @PostMapping("/disableBytypeId")
    public Result disableBytypeId(@RequestBody DisableTypeForm disableTypeForm){
        return defectTypeService.updateBytypeId(disableTypeForm);
    }

    /**
     * 获取所有类型
     * @return
     */
    @ApiOperation("获取所有类型")
    @GetMapping("/GetAllType")
    public Result GetAllType(){
        return defectTypeService.FindAllType();
    }
}

